package org.redswallow.util;

import java.util.Map;

public final class Utils {
	
	public static boolean isBlank(String input) {
		return input == null || input.length() == 0 || input.trim().length() == 0;
	}
	
	public static boolean isNonBlank(String input) {
		return !isBlank(input);
	}
	
	public static String printMap(Map<String, String[]> map) {
		StringBuilder sb = new StringBuilder("map size:");
		sb.append(map.size());
		sb.append(" content:{");
		Boolean isFirst,is1=true;
		for(String key: map.keySet()) {
			if (is1)
				is1 = false;
			else
				sb.append(",");
			
			sb.append(key);
			sb.append(":");
			Object values = map.get(key);
			if (values instanceof  String[]) {
				sb.append("[");
				isFirst = true;
				for(String value : (String[])values) {
					if (isFirst)
						isFirst = false;
					else
						sb.append(",");
					sb.append(value);
				}
				sb.append("]");
			}else{
				sb.append(values);
			}
		}
		sb.append("}");
		
		return sb.toString();
	}
}
